import React from 'react';
const Login = () => {
    const login = async (values: any) => 
    {
        let result = await React.HTTP.post('/business/login', values)
        if (result.code == 1) 
        {
            React.Cookie.save('Business', result.data)
            React.success(result.msg)
            window.location.href = '/business/index'
        }
        else 
        {
            React.error(result.msg)
        }
    }

    return (
        <>
            <link rel="stylesheet" href="/assets/css/login.css" />
            <div className="headers">
                <div className="userinfo">
                    <div className="avatar"></div>
                </div>
                <div className="corrugated">
                    <div className="wave_top wave_item"></div>
                    <div className="wave_middle wave_item"></div>
                </div>
            </div>
            <div className="login">

                {/* 表单信息 */}
                <React.UI.Form
                    layout='horizontal'
                    mode='card'
                    onFinish={login}
                    initialValues={{
                        mobile: '13060808046',
                        password: '123'
                    }}
                    footer={
                        <React.UI.Button block shape='rounded' type='submit' color='warning' size='large'>
                            登陆注册
                        </React.UI.Button>
                    }
                >
                    <React.UI.Form.Item
                        name='mobile'
                        label='手机号码 '
                        rules={[{ required: true, message: '请填写手机号码' }, {
                            pattern: /^1[3456789]\d{9}$/, message: '手机号格式不对'
                        }]}
                    >
                        <React.UI.Input placeholder='请填写手机号码' />
                    </React.UI.Form.Item>
                    <React.UI.Form.Item
                        name='password'
                        label='密码'
                        rules={[{ required: true, message: '请填写密码' }]}
                    >
                        <React.UI.Input clearable type='password' placeholder='请填写密码' />
                    </React.UI.Form.Item>
                </React.UI.Form>

                <div className="tips">
                    <React.Router.NavLink to="/" >
                        首页
                    </React.Router.NavLink>
                </div>
            </div>
        </>
    )
}

export default Login;